package com.home.auto_navigation.ui.pages;

import java.util.HashMap;
import java.util.Map;

import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

import com.home.auto_navigation.common.AutoNavigationFileDecorator;
import com.home.auto_navigation.common.api.NavigationLink;
import com.home.auto_navigation.ui.AbstractPageObject;
import com.home.auto_navigation.ui.controllers.Button;

public class DownloadsPage extends AbstractPageObject {
	@FindBy(xpath = "/html/body/div[2]/div[4]/div/div/div/div[3]/div/h1")
	private WebElement uniqueElement;
	@NavigationLink(successor = JavaEEPage.class)
	@FindBy(linkText = "Java for Developers")
	private Button javaEE;

	public DownloadsPage() {
		PageFactory.initElements(new AutoNavigationFileDecorator(getDriver()), this);
		this.successors = new HashMap<Class<? extends AbstractPageObject>, Button>();
		this.successors.put(JavaEEPage.class, javaEE);
	}

	@Override
	public boolean isExist() {
		try {
			return uniqueElement.isDisplayed();
		} catch (NoSuchElementException e) {
			return false;
		}
	}

	@Override
	public void invokeSuccessor(Map<String, String> businessData,
			Class<? extends AbstractPageObject> page) {
		// TODO Auto-generated method stub

	}

}
